package cn.mw.cmdb.entity;

import cn.mw.cmdb.param.MwPropertyCustomParam;
import cn.mw.cmdb.param.MwRuleModelDiscoveryEnum;
import cn.mw.cmdb.param.MwRuleTypeEnum;
import cn.mw.cmdb.service.ServiceChoose;
import cn.mw.cmdb.service.impl.MwCustomRuleServiceImpl;
import cn.mw.cmdb.util.DataCreateInfo;
import cn.mw.components.mongodb.anno.AutoId;
import cn.mw.components.mongodb.anno.CMDBProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;
import java.util.List;

/**
 * 资产扫描自定义规则
 */
@Data
@Document("mw_custom_rule_table")
public class MwCustomRuleInfo extends DataAuth implements ServiceChoose, DataCreateInfo {
    @CMDBProperty
    @AutoId
    @Schema(description = "id")
    protected String id;

    @Schema(description = "规则名称")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private String ruleName;

    @Schema(description = "规则类型:纳管规则-manageRule；添加规则-insertRule")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private MwRuleTypeEnum ruleType;

    @Schema(description = "模型识别类型：手动-manual；自动-auto")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private MwRuleModelDiscoveryEnum discoveryType;

    @Schema(description = "属性模型id")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private String modelId;

    @Schema(description = "属性数据")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private List<MwPropertyCustomParam> propertyInfos;

    @Schema(description = "监控引擎Id")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private String monitorServerId;

    @Schema(description = "引擎分组")
    @CMDBProperty(searchType = PropertyTypeInt.ID, keywordSearch = true)
    private Integer proxyType;

    @Schema(description = "采集引擎Id")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    private String pollingEngineId;

    @CMDBProperty(logicDel = true, searchType = PropertyTypeList.ID)
    protected Boolean delFlag = false;

    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "创建人")
    protected Long creater;

    @CMDBProperty(searchType = PropertyTypeTime.ID)
    @Schema(description = "创建时间")
    protected Date createTime;

    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "修改人")
    protected Long modifier;

    @CMDBProperty(searchType = PropertyTypeTime.ID)
    @Schema(description = "修改时间")
    protected Date modificationTime;
    @CMDBProperty
    @Schema(description = "功能模块")
    private List<String> functionModuleList;
    @CMDBProperty
    @Schema(description = "忽略CODE检查")
    private Boolean ignoreCodeCheck;
    @CMDBProperty
    @Schema(description = "是否立即检查")
    private Boolean checkNow = false;
    @CMDBProperty
    @Schema(description = "纳管是否使用随机名称")
    private Boolean randomNameFlag = false;
    @CMDBProperty
    @Schema(description = "是否Trunk监控")
    private Boolean mw_trunkMonitorFlag = false;
    @CMDBProperty
    @Schema(description = "自定义端口信息")
    private List<CustomNanotubeType> customPortList;

    @Data
    public static class CustomNanotubeType {
        private String type;

        private Integer port;
    }


    @Override
    public String getServiceId() {
        return MwCustomRuleServiceImpl.ID;
    }
}
